//
//  ConvenienceInit.swift
//  Edaixi-iOS
//
//  Created by 刘树华 on 2017/11/28.
//  Copyright © 2017年 刘树华. All rights reserved.
//

import Foundation
import UIKit
extension UILabel {
    
    convenience init(text:String? = "" ,font:CGFloat? = 15 ,textAlignment:NSTextAlignment = .center , textColor:UIColor? = UIColor.black ,bgColor:UIColor? = nil) {
        self.init()
        self.text = text
        self.backgroundColor = bgColor
        self.textColor = textColor
        self.textAlignment = textAlignment
        self.font = UIFont.systemFont(ofSize: font ?? 15)
    }
    
    
}

extension UITextField {
    
    convenience init(place:String? = "",textColor:UIColor? = UIColor.black,textAlignment:NSTextAlignment = .center,boder:UITextBorderStyle = .none,bgColor:UIColor?=nil) {
        self.init()
        self.backgroundColor = bgColor
        self.textAlignment = textAlignment
        self.textColor = textColor
        self.placeholder = place
        self.borderStyle = boder
    }
    
}

extension UIButton {
    
    convenience init(title:String="",titleColor:UIColor?    = UIColor.black,bgColor:UIColor?=nil) {
        self.init()
        self.setTitle(title, for: .normal)
        self.setTitleColor(titleColor, for: .normal)
        self.backgroundColor = bgColor
    }
    
}

extension UIImageView {
    
    convenience init(imageName:String?) {
        self.init()
        self.image = UIImage(named:validStr(data: imageName))
    }
    
}

